package csel.controller.commands;

import java.util.HashMap;

import csel.controller.commandutil.Parameterizable;
import csel.controller.enums.ActionEnum;
import csel.model.BodyParts;
import csel.model.Model;
import csel.model.entity.ItemIndexOutOfBoundsException;

public class NBUnequipCommand implements Parameterizable
{
	private Model model;
	private ActionEnum actionEnum;
	private HashMap<ActionEnum, BodyParts> slotBodyPartHash;


	public NBUnequipCommand(Model model)
	{
		super();
		this.model = model;
		this.slotBodyPartHash = new HashMap<ActionEnum, BodyParts>();
		slotBodyPartHash.put(ActionEnum.SLOT_1, BodyParts.Head);
		slotBodyPartHash.put(ActionEnum.SLOT_2, BodyParts.Torso);
		slotBodyPartHash.put(ActionEnum.SLOT_3, BodyParts.Legs);
		slotBodyPartHash.put(ActionEnum.SLOT_4, BodyParts.Shoes);
		slotBodyPartHash.put(ActionEnum.SLOT_5, BodyParts.Lefthand);
		slotBodyPartHash.put(ActionEnum.SLOT_6, BodyParts.Righthand);
	}

	public void parameterize(ActionEnum actionEnum)
	{
		this.actionEnum = actionEnum;
	}

	public void execute()
	{
		try
		{
			model.getPlayerCharacter().unequip(
					slotBodyPartHash.get(actionEnum));
		} catch (ItemIndexOutOfBoundsException e)
		{
			
		}
	}

	public NBUnequipCommand clone()
	{
		NBUnequipCommand clone;
		try
		{
			clone = (NBUnequipCommand)super.clone();
			return clone;
		} catch (CloneNotSupportedException e)
		{
            throw new InternalError(e.toString());
		}
	}
}
